package auth



func CreatePositionLevelFactory() *PositionIdLevel {
	e := &PositionIdLevel{
		Levels: make(map[int]PositionLevel),
	}
	e.initLevels()
	return e
}


// 初始化所有等级信息
func (e *PositionIdLevel) initLevels() {
	e.Levels[PositionLevelGeneralStaff] = PositionLevel{
		Level: PositionLevelGeneralStaff,
		Title: PositionTitleGeneralStaff,
	}
	e.Levels[PositionLevelManager] = PositionLevel{
		Level: PositionLevelManager,
		Title: PositionTitleManager,
	}
	e.Levels[PositionLevelSupervisor] = PositionLevel{
		Level: PositionLevelSupervisor,
		Title: PositionTitleSupervisor,
	}
}

// 根据等级获取PositionLevel，使用map查找替代switch语句
func (e *PositionIdLevel) GetPositionLevelByLevel(level int) PositionLevel {
	if positionLevel, exists := e.Levels[level]; exists {
		return positionLevel
	}
	return PositionLevel{
		Level: PositionLevelUnknown,
		Title: PositionTitleUnknown,
	}
}